package com.markhsiu.store.disk;

import java.io.File;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

/**
 * 读写文件，多线程写读
 * 
 * @author Mark Hsiu
 */
abstract class MapFile {

	 static final int CACHE_HEAD = 3;
	// Cache = 16k  SIZE = 16.9M
	private static final int CHUNK_SIZE = 16 * 1024 * 1024;//50||54
	private static final int HEAD_LEN = 0; 
	
	protected RandomAccessFile randomFile;
	protected FileChannel channel;
 
	public MapFile(File file) {
		try {
			this.randomFile = new RandomAccessFile(file, "rw");
			this.channel = this.randomFile.getChannel();
			 
		} catch (Exception e) {
			throw new IllegalArgumentException(e);
		}
		
	}
 
 
 
	public int headLen(){
		return HEAD_LEN;
	}
	
	public int size() {
		return CHUNK_SIZE;
	}
}
